<!DOCTYPE html>
<html>
    <head>
        <title>{$title}</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta name="description" content="{$description}">
        <meta name="author" content="{$author}">
        <!-- Le styles -->
        <link href="../Public/css/bootstrap.min.css" rel="stylesheet">
        <link href="../Public/css/bootstrap-responsive.css" rel="stylesheet">
        <script type="text/javascript" src="http://api.map.baidu.com/api?v=1.3"></script>
        <script type="text/javascript" src="http://lib.sinaapp.com/js/jquery/1.7.2/jquery.min.js"></script>
        <script type="text/javascript" src="../Public/js/cookie.js"></script>
    </head>
    <body>

    <body data-spy="scroll" data-target=".subnav" data-offset="50">

        <div class="container">
 

            <div id="header">

                <section id="logo">   
                    <div class="page-header">
                        <div class="row">
                            <div class="span2">
                                <h1><a href="/">去玩吗？</a></h1>
                            </div>
                            <div class="span4">
                                {$weather}15日星期日 	夜间 		多云 	低温 27℃ 	无持续风向 	微风 
                            </div>
                            <div class="span2">
                                <a href="#" class="btn  btn-large  btn-success"><i class="icon-pencil icon-white"></i>发布活动</a>
                            </div>
                            <div class="span4">
                                温柔的大海-手机-消息-帐号
                            </div>
                        </div>

                    </div>
                </section>

            </div>

            <section id="forms">

                <div class="row">
                    <div class="span2">

                        <div style="padding: 8px 0;" class="well">
                            <ul class="nav nav-list">
                                <li class="active"><a>会员中心</a></li>
                                <include file="Public:menu" />
                            </ul>

                        </div>

                    </div>

                    <div class="span7">

                        <form class="form-horizontal" name="member" method="post" action="__URL__/doedit">
                            <fieldset>
                                <legend>我的位置</legend>
                                <div style="width:750px;height:400px;border:1px solid gray" id="mymap"></div>
                                <div>请输入:<input type="text" id="suggestId" size="20" value="百度" style="width:470px;" /><span id="checkLocation" style="display: none"><a href="javascript:void(0)">自动获取位置</a></span></div><div id="searchResultPanel" style="border:1px solid #C0C0C0;width:150px;height:auto;display: none"></div>

                                <div class="form-actions">
                                    <button class="btn btn-primary" type="submit">保存</button>
                                </div>
                            </fieldset>
                        </form>

                    </div>

                    <div class="span3"></div>

                </div>

            </section>

            <!-- Footer
             ================================================== -->
            <footer class="footer">
                <p class="pull-right"><a href="#">返回顶部</a></p>
                <p>©2011-2012 去玩吗？<a href="http://weibo.com/33kuai" target="_blank">去玩吗新浪微博</a> | 关于去玩吗 | 开放API | 意见反馈 | 联系我</p>
            </footer>

        </div><!-- /container -->

    </body>
</html>

<script type="text/javascript">
    function G(id) {
        return document.getElementById(id);
    }

    var map = new BMap.Map("mymap");
    var point = new BMap.Point("{$lng}","{$lat}");
    map.centerAndZoom(point,16);
    map.enableScrollWheelZoom();

    var ac = new BMap.Autocomplete(    //建立一个自动完成的对象
    
    {"input" : "suggestId"
        ,"location" : map
    });
    
    var myIcon = new BMap.Icon("{$extend.figureurl}", new BMap.Size(300,157));
    var marker = new BMap.Marker(new BMap.Point("{$lng}","{$lat}"),{icon:myIcon}); // 创建标注
    map.addOverlay(marker);
    marker.enableDragging(true);
    marker.addEventListener("dragend", function(e){
        $.cookie('lat', e.point.lat);
        $.cookie( 'lng', e.point.lng);
    }) 
    

    ac.addEventListener("onhighlight", function(e) {  //鼠标放在下拉列表上的事件
        var str = "";
        var _value = e.fromitem.value;
        var value = "";
        if (e.fromitem.index > -1) {
            value = _value.province +  _value.city +  _value.district +  _value.street +  _value.business;
        }    
        str = "FromItem<br/>index = " + e.fromitem.index + "<br/>value = " + value;
    
        value = "";
        if (e.toitem.index > -1) {
            _value = e.toitem.value;
            value = _value.province +  _value.city +  _value.district +  _value.street +  _value.business;
        }    
        str += "<br/>ToItem<br/>index = " + e.toitem.index + "<br/>value = " + value;
        G("searchResultPanel").innerHTML = str;
    });

    var myValue;
    ac.addEventListener("onconfirm", function(e) {    //鼠标点击下拉列表后的事件
        var _value = e.item.value;
        myValue = _value.province +  _value.city +  _value.district +  _value.street +  _value.business;
        G("searchResultPanel").innerHTML ="onconfirm<br/>index = " + e.item.index + "<br/>myValue = " + myValue;
    
        setPlace();
    });

    function setPlace(){
        map.clearOverlays();    //清除地图上所有覆盖物
        function myFun(){
            var pp = local.getResults().getPoi(0).point;    //获取第一个智能搜索的结果
            map.centerAndZoom(pp, 18);
            var marker = new BMap.Marker(pp);
            map.addOverlay(marker);    //添加标注
            marker.enableDragging(true); 
            marker.addEventListener("dragend", function(e){  
                $.cookie('lng',e.point.lng);
                $.cookie('lat',e.point.lat);
            }) 
        }
        var local = new BMap.LocalSearch(map, { 
            onSearchComplete: myFun
        });
        local.search(myValue);
    }
</script>


<script type="text/javascript">
    function success(position) {
        $.cookie("lng", position.coords.longitude);
        $.cookie("lat", position.coords.latitude);
        
        var map = new BMap.Map("mymap");
        var point = new BMap.Point($.cookie("lng"),$.cookie("lat"));
        map.centerAndZoom(point,16);
        map.enableScrollWheelZoom();

        var ac = new BMap.Autocomplete(    //建立一个自动完成的对象
    
        {"input" : "suggestId"
            ,"location" : map
        });
    
        var marker = new BMap.Marker(new BMap.Point($.cookie("lng"),$.cookie("lat"))); // 创建标注
        map.addOverlay(marker);
        marker.enableDragging(true);
        marker.addEventListener("dragend", function(e){
            $.cookie('lat', e.point.lat);
            $.cookie( 'lng', e.point.lng);
        }) 
        
        
    }
    function error(msg){
        alert(msg);
    }
    $(document).ready(function(){
        
        $('#checkLocation').css('display', '');
        $("#checkLocation").click(function(){
            if (navigator.geolocation) {
                
                navigator.geolocation.getCurrentPosition(success, error,{enableHighAccuracy:true, 
                    maximumAge:30000, 
                    timeout:27000});
            } else {
                error('not supported');
            }  

        });
    });
</script>

    